package com.example.mapp.buildSql;

import com.example.entity.authority.SystemRole;
import com.example.entity.authority.SystemRoleType;
import org.apache.ibatis.jdbc.SQL;

/**
 * Created by youkun on 2018/3/16.
 */
public class SystemRoleTypeMappSql {

    public String queryList(SystemRoleType systemRoleType){
        String select = " id,role_type_name,role_type_describe ";

        String table = " system_role_type ";

        String whereParam="";
        if(null!=systemRoleType.getRoleTypeName() && systemRoleType.getRoleTypeName().length()>0){
            whereParam+=" and role_type_name = #{roleTypeName}";
        }
        if(null!=systemRoleType.getId()){
            whereParam+=" and id = #{id}";
        }
        String  where = "1=1 " +whereParam;
        return new SQL(){{
            SELECT(select);
            FROM(table);
            WHERE(where);
        }
        }.toString();
    }
}
